#!/bin/env python

import websocket
import json
import zlib

symbols = set()


def on_message(ws, message):
  data = json.loads(zlib.decompress(bytes(message), 15 + 32))
  print(data)
  if 'ping' in data:
    payload = {'pong': data['ping']}
    ws.send(json.dumps(payload))


def on_open(ws):
  payload = {
      'sub': 'market.xrpbtc.depth.step4',
      'id': 'id0',
  }
  ws.send(json.dumps(payload))

  payload = {
      'sub': 'market.elfbtc.depth.step4',
      'id': 'id0',
  }
  ws.send(json.dumps(payload))


if __name__ == '__main__':
  ws = websocket.WebSocketApp('wss://api.huobi.pro/ws', on_message=on_message)
  ws.on_open = on_open
  ws.run_forever()
